package com.nb.sse;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.rules.DateType;


/**
 * 代码生成器
 */
public class CodeGenerator {

    public static void main(String[] args) {





        String local = "jdbc:mysql://127.0.0.1:3306/db_message?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&useSSL=false";
        String uname ="root";
        String pwd= "root";
        //生成tidb 对应表
        generatorCode(local, uname, pwd);

    }

    private static void generatorCode(String xeasy, String uname, String pwd) {
        FastAutoGenerator.create(xeasy, uname, pwd)

                .globalConfig(builder -> {
                    builder
                            .dateType(DateType.ONLY_DATE)
                            //.enableSwagger() // 开启 swagger 模式
                            //.fileOverride() // 覆盖已生成文件
                            .dateType(DateType.TIME_PACK)
                            .outputDir("D:\\data\\codeGen"); // 指定输出目录
                })

                .packageConfig(builder -> {
                    builder.parent("com.nb.sse") // 设置父包名
                            .entity("entity")
                            .mapper("mapper")
                            .service("service")
                            .serviceImpl("service.impl")
                            .controller("controller");
                            //.moduleName("system") // 设置父包模块名
                           // .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "D:\\data\\codeGen\\mapper")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.entityBuilder()
                            .enableLombok().build();//开启Lombok


                    builder
                            .addInclude("sys_notice").addTablePrefix("");// 设置需要生成的表名

                    builder.mapperBuilder().enableBaseColumnList().enableBaseResultMap();
                })
                //.templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}
